const mongoose = require("mongoose");

const permissionSchema = new mongoose.Schema({
  label: {
    type: String,
    required: true,
  },
  method: {
    type: String,
    required: true,
  },
  url: {
    type: String,
    required: true,
  },
});

const roleInfoModel = new mongoose.Schema(
  {
    name: {
      type: String,
      required: true,
      unique: true,
    },
    description: {
      type: String,
      required: false,
    },
    tag: {
      type: String,
      required: false,
    },
    level: {
      type: Number,
      required: true,
    },
    permissions: [permissionSchema],
    userCount: {
      type: Number,
      default: 0,
    },
  }
  // {
  //   _id: false,
  // }
);

module.exports = mongoose.model("Role", roleInfoModel);
